package com.qihunet.springbootjwt.config;

import java.util.Collection;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * @author gary
 */
public class JwtUser implements UserDetails {

	private static final Long serialVersionUID = 1L;
	
	private final Long id;
	private final String displayUserId;
    private final String username;
    private final String password;
    private final Integer userType;
    private final Collection<? extends GrantedAuthority> authorities;
    private final boolean isEnabled;

    public JwtUser(
            Long id,
          String displayUserId,
          String username,
          String password,
          Integer userType,
          Collection<? extends GrantedAuthority> authorities,
          boolean isEnabled
     
    ) {
        this.displayUserId=displayUserId;
        this.id = id;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
        this.isEnabled = isEnabled;
        this.userType = userType;
    }

    @JsonIgnore
    public Long getId() {
        return id;
    }

    @JsonIgnore
    public String getDisplayUserId() {
        return displayUserId;
    }

    @JsonIgnore
    public Integer getUserType(){
        return userType;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @JsonIgnore
    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @JsonIgnore
    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }



    @JsonIgnore
    @Override
    public String getPassword() {
        return password;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isEnabled() {
        return isEnabled;
    }
}

